#include"../include/chassis.h"

// 底盘
// 构造函数定义
Chassis::Chassis(const std::string &id, const std::string &model,
                 int wheelbase, int tread, int groundClearance,
                 float minTurningRadius, const std::string &driveType,
                 float maxRange, const std::string &tireType, int tireSize)
    : id(id), model(model), wheelbase(wheelbase), tread(tread),
      groundClearance(groundClearance), minTurningRadius(minTurningRadius),
      driveType(driveType), maxRange(maxRange), tireType(tireType), tireSize(tireSize) {}
          
Chassis::Chassis(std::string id)
    : Chassis(id, "SCOUT MINI", 451, 490, 115, 0.0f, "四轮四驱", 10.0f, "公路轮", 175) {}

// 将属性写入文件的方法
void Chassis::writeToFile(std::ofstream &file) {
    if (file.is_open()) {
        file <<"底盘：" << std::endl;
        file << " Chassis ID: " << id << std::endl;
        file << " Model: " << model << std::endl;
        file << " Wheelbase: " << wheelbase << std::endl;
        file << " Tread: " << tread << std::endl;
        file << " Ground Clearance: " << groundClearance << std::endl;
        file << " Minimum Turning Radius: " << minTurningRadius << std::endl;
        file << " Drive Type: " << driveType << std::endl;
        file << " Maximum Range: "  << maxRange << std::endl;
        file << " Tire Type: " << tireType << std::endl;
        file << " Tire Size: " << tireSize << std::endl;
    }
}

// 打印属性的方法
void Chassis::print() const {
    std::cout <<"底盘：" << std::endl;
    std::cout << " Chassis ID: " << id << std::endl;
    std::cout << " Model: " << model << std::endl;
    std::cout << " Wheelbase: " << wheelbase << std::endl;
    std::cout << " Tread: " << tread << std::endl;
    std::cout << " Ground Clearance: " << groundClearance << std::endl;
    std::cout << " Minimum Turning Radius: "  << minTurningRadius << std::endl;
    std::cout << " Drive Type: " << driveType << std::endl;
    std::cout << " Maximum Range: "  << maxRange << std::endl;
    std::cout << " Tire Type: " << tireType << std::endl;
    std::cout << " Tire Size: " << tireSize << std::endl;
}

std::string Chassis::getId() const{
    return id;
}

// 设置编号的方法定义
void Chassis::setId(const std::string &newId) {
    id = newId;
}

// 设置型号的方法定义
void Chassis::setModel(const std::string &newModel) {
    model = newModel;
}

// 设置轴距的方法定义
void Chassis::setWheelbase(int newWheelbase) {
    wheelbase = newWheelbase;
}

// 设置轮距的方法定义
void Chassis::setTread(int newTread) {
    tread = newTread;
}

// 设置最小离地间隙的方法定义
void Chassis::setGroundClearance(int newGroundClearance) {
    groundClearance = newGroundClearance;
}

// 设置最小转弯半径的方法定义
void Chassis::setMinTurningRadius(float newMinTurningRadius) {
    minTurningRadius = newMinTurningRadius;
}

// 设置驱动形式的方法定义
void Chassis::setDriveType(const std::string &newDriveType) {
    driveType = newDriveType;
}

// 设置最大行程的方法定义
void Chassis::setMaxRange(float newMaxRange) {
    maxRange = newMaxRange;
}

// 设置轮胎类型的方法定义
void Chassis::setTireType(const std::string &newTireType) {
    tireType = newTireType;
}

// 设置轮胎尺寸的方法定义
void Chassis::setTireSize(int newSize) {
    tireSize = newSize;
}